<?php
class Tree extends Zend_Db_Table
{
	protected $_name ="tree";
	protected $_primary = 'tree_id';

 //根据tree_id 查询tree
    public function gettreeBytree_id($tree_id){
          $select = $this->select();
          $select->where("tree_id=".$tree_id);
          return $this->fetchAll($select)->toArray();
    }
//取得所有的标签树
    public function getAllTrees($page,$perpage,$search_name,$search_key){
          $where = "1=1";
          if($search_name!=""){
              $where.= " and name like '%$search_name%'";
          }
          if($search_key!=""){
              $where.= " and key_word like '%$search_key%'";
          }
          $select = $this->select();
          $select->where($where);
          if($page!=""){
          $select->limitPage($page,$perpage);
          }
          $select->order('create_time asc');
          return $this->fetchAll($select)->toArray();
    }


 //更新tree
    public function updatetreeBytree_id($array,$tree_id){

		$db = $this->getAdapter();
		$where=$db->quoteInto('tree_id = ?', $tree_id);
		$this->update($array, $where);
                return true;
	}
//删除tree
     public function deltreeBytree_id($tree_id){
          $where = 'tree_id = '. $tree_id;
         $this->delete($where);
         return true;
    }

}

